package com.ruoyi.system.service.impl;

import com.ruoyi.system.domain.FaPiao;
import com.ruoyi.system.mapper.FaPiaoMapper;
import com.ruoyi.system.service.IFaPiaoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 发票信息Service业务层处理
 */
@Service
public class FaPiaoServiceImpl implements IFaPiaoService {

    @Autowired
    private FaPiaoMapper faPiaoMapper;

    /**
     * 查询发票信息
     */
    @Override
    public FaPiao selectFaPiaoById(Long fapiaoId) {
        return faPiaoMapper.selectFaPiaoById(fapiaoId);
    }

    /**
     * 查询发票信息列表
     */
    @Override
    public List<FaPiao> selectFaPiaoList(FaPiao faPiao) {
        return faPiaoMapper.selectFaPiaoList(faPiao);
    }

    /**
     * 新增发票信息
     */
    @Override
    @Transactional
    public int insertFaPiao(FaPiao faPiao) {
        // 设置默认值
        if (faPiao.getKpStatus() == null) {
            faPiao.setKpStatus(0); // 默认未提交
        }

        return faPiaoMapper.insertFaPiao(faPiao);
    }

    /**
     * 修改发票信息
     */
    @Override
    @Transactional
    public int updateFaPiao(FaPiao faPiao) {
        return faPiaoMapper.updateFaPiao(faPiao);
    }

    /**
     * 删除发票信息
     */
    @Override
    @Transactional
    public int deleteFaPiaoById(Long fapiaoId) {
        return faPiaoMapper.deleteFaPiaoById(fapiaoId);
    }

    /**
     * 批量删除发票信息
     */
    @Override
    @Transactional
    public int deleteFaPiaoByIds(Long[] fapiaoIds) {
        return faPiaoMapper.deleteFaPiaoByIds(fapiaoIds);
    }
}
